var CmsFieldGroupControl = Class.create(BaseControl, {
    collapsed:null,

    observeEvent: function($super)
    {
        $super();
        this.collapsed = false;
        var me = this;
        this.find('.collapse_header').invoke('observe', 'click', this.toggleCollapse.bind(this));
    },

    toggleCollapse: function(e)
    {
        if (this.collapsed) this.expand();
        else this.collapse();
        this.find('.collapse_button').invoke('toggleClassName', 'collapsed');
    },

    collapse: function(e)
    {
        this.down('.fieldset_body').slideUp({queue:'end'});
        this.collapsed = true;
    },

    expand: function(e)
    {
        this.down('.fieldset_body').slideDown({queue:'end'});
        this.collapsed = false;
    }
});